﻿using Bids.Core.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.OpenAccess;
using Telerik.OpenAccess.Metadata;
using Telerik.OpenAccess.Metadata.Fluent;
namespace Bids.Core.DomainObjects
{
	/// <summary>
	/// 心情/状态
	/// </summary>
	[Serializable]
    public class Mood : IEntity
	{
        public Mood()
        {
            this.MoodReplys = new List<MoodReply>();
        }
		/// <summary>
		/// 
		/// </summary>
        public virtual int ID { set; get; }
		
		/// <summary>
		/// 发件人Id
		/// </summary>
        public virtual int UserId { set; get; }
		
		/// <summary>
		/// 正文
		/// </summary>
        public virtual string Content { set; get; }
		/// <summary>
		/// 时间
		/// </summary>
        public virtual DateTime CreateTime { set; get; }

        public virtual User User { get; set; }
        public virtual IList<MoodReply> MoodReplys { get; set; }
        public static MappingConfiguration<Mood> CreateConfiguration()
        {
            var threadMapping = new MappingConfiguration<Mood>();
            threadMapping.MapType(t => new
            {
                t.ID,
                t.UserId,
                t.Content,
                t.CreateTime

            }).ToTable("Moods");
            threadMapping.HasProperty(t => t.ID).IsIdentity(KeyGenerator.Autoinc);
            threadMapping.HasAssociation(t => t.User).WithOpposite(d => d.Moods).HasConstraint((t, d) => t.UserId == d.ID);
            return threadMapping;
        }
	}

}

